import request from "@/util/request";

export function UploadTIF (formData, callback) {
    return request({
        url: '/api/process_tif/',
        method: 'POST',
        header: {
            'accept': 'application/json',
            "Content-Type": "multipart/form-data"
        },
        data: formData,
        timeout: 6000000000,
        onUploadProgress: (progressEvent) => {
            callback && callback(Math.round(
                (progressEvent.loaded / progressEvent.total) * 100
            ));
        },
    })
}
export function autoOffset(data) {
    return request({
        url: '/api/autoOffset/',
        header: {
            'accept': 'application/json',
            "Content-Type": "application/x-www-form-urlencoded"
        },
        method: "POST",
        timeout: 6000000000,
        data
    })
}
export function calibration(data) {
    return request({
        url: '/api/georeference/',
        header: {
            'accept': 'application/json',
            "Content-Type": "application/x-www-form-urlencoded"
        },
        method: "POST",
        timeout: 6000000000,
        data
    })
}

export function deleteTiles(uuid_affine) {
    return request({
        url: `/api/deleteTiles/${uuid_affine}`,
        header: {
            'accept': 'application/json',
        },
        method: "GET",
        timeout: 6000000000
    })
}


export function generateTiles(data) {
    return request({
        url: '/api/generate_tiles/',
        header: {
            'accept': 'application/json',
            "Content-Type": "application/json"
        },
        method: "POST",
        timeout: 6000000000,
        data
    })
}

export function downloadTIF(params) {
    return request({
        url: `/api/download/${params['fileId']}`,
        method: "GET"
    })
}
